package co.yixiang.modules.quartz.task;

import co.yixiang.modules.shop.domain.YxStoreProduct;
import co.yixiang.modules.shop.service.YxStoreProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 认购商品锁定释放定时器
 *
 * @author frq
 * @date 2020-06-28
 */
@Component
@Slf4j
public class GoodsLockReleaseTimer {

    @Autowired
    private YxStoreProductService yxStoreProductService;

    public void run(){
        List<YxStoreProduct> list=yxStoreProductService.findGoodsLock();
        for(YxStoreProduct storeProduct:list){
            try {
                yxStoreProductService.updateLockStatus(String.valueOf(storeProduct.getId()),0);
            }catch (Exception e){
                log.error("释放商品失败:"+"商品id："+storeProduct.getId());
            }
        }
    }
}
